/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: Frank
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/9/19 15:41
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.job.model;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 用户信息
 * @author Frank
 * @version 1.0.0.1
 * @since JDK 1.8
 */
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "xxl_job_user")
public class JobUser implements Serializable {

    private static final long serialVersionUID = 3662537419127864898L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false, unique = true, insertable = false, updatable = false)
    private Integer id;

    /**
     * 账号
     */
    @NotBlank
    @Size(max = 50)
    @Column(name = "username", unique = true, nullable = false)
    private String username;

    /**
     * 密码
     */
    @NotBlank
    @Size(max = 50)
    @Column(name = "password", nullable = false)
    private String password;

    /**
     * 角色：0-普通用户、1-管理员
     */
    @NotNull
    @Column(name = "role", columnDefinition = "tinyint(4) NOT NULL COMMENT '角色：0-普通用户、1-管理员'")
    private int role;

    /**
     * 权限：执行器ID列表，多个逗号分割
     */
    @Size(max = 255)
    @Column(name = "permission")
    private String permission;

    public JobUser(@NotBlank @Size(max = 50) String username, @NotBlank @Size(max = 50) String password, @NotNull int role, @Size(max = 255) String permission) {
        this.username = username;
        this.password = password;
        this.role = role;
        this.permission = permission;
    }
}
